package com.topisv.tms.web.document;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.topisv.tms.entity.JSONParam;
import com.topisv.tms.entity.QueryParamHolder;
import com.topisv.tms.entity.WaveSortBill;
import com.topisv.tms.service.document.WaveSortService;
import com.topisv.tms.web.base.BaseDataTableController;

/**
 * 波次分拣
 * @author Administrator
 *
 */
@Controller
@RequestMapping(value="/v2/waveSort")
public class WaveSortController extends BaseDataTableController{
	
	@Autowired
	private WaveSortService waveSortService;
	
	@RequestMapping(value="waveSortList")
	public String list(){
		return "document/waveSortList";
	}
	
	@RequestMapping(value="pageList")
	public void page(@RequestBody JSONParam[] paramJson, HttpServletRequest request,HttpServletResponse response){
		try {
			QueryParamHolder paramHolder = collectParam(paramJson);
			Page<WaveSortBill> page = waveSortService.findWaveSortBill(paramHolder);
			//封装成json
			response.getWriter().print(bulidJSON(page));
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	@RequestMapping(value="waveSort_Create",method=RequestMethod.GET)
	public String waveSort_create(Model model){
		model.addAttribute("status", 0);
		model.addAttribute("action", "create");
		return "document/waveSortForm";
	}
	
}
